﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.HeadUpWindow.CUiSmartNoteHeadUpWindow
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;
using System.Windows.Shapes;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.HeadUpWindow;

public class CUiSmartNoteHeadUpWindow : CUiHeadUpWindow, IComponentConnector
{
  private bool m_isObjectSet;
  internal CApSmartNotePictureDataContainer SmartNodeData;
  internal System.Windows.Controls.Image PictureFrame;
  internal Button PrevMedia;
  internal TextBlock NumOutOfMedia;
  internal Button NextMedia;
  internal Button DeleteMedia;
  internal Canvas svg61;
  internal Canvas cmdTrash24_1_;
  internal Path Path_9752;
  internal Path Path_9753;
  internal System.Windows.Shapes.Rectangle Rectangle_10388;
  internal Path Path_9754;
  internal Grid NoteGrid;
  internal ComboBox StatusComboBox;
  internal TextBox DescriptionTextBox;
  internal Button ShowTextBoxButton;
  internal TextBox HistoryTextBox;
  internal Button ApplyButton;
  private bool _contentLoaded;

  public CUiSmartNoteHeadUpWindow() => this.InitializeComponent();

  public override void SetObject(ITxObject obj)
  {
    TxNote note = obj as TxNote;
    if (!TxNote.op_Inequality(note, (ITxObject) null))
      return;
    this.SmartNodeData.Load(note);
    this.CalcWindowHeight((double) this.SmartNodeData.PicContainer.Width, (double) this.SmartNodeData.PicContainer.Height);
    this.m_isObjectSet = true;
  }

  private void CalcWindowHeight(double picWidth, double picHeight)
  {
    int height = (int) this.PictureFrame.Height;
    double width = this.PictureFrame.Width;
    int num;
    if (string.IsNullOrEmpty(this.SmartNodeData.PicContainer.FullPath))
    {
      this.PrevMedia.Visibility = Visibility.Collapsed;
      this.NextMedia.Visibility = Visibility.Collapsed;
      this.NumOutOfMedia.Visibility = Visibility.Collapsed;
      this.DeleteMedia.Visibility = Visibility.Collapsed;
      num = (int) picHeight;
    }
    else
      num = (int) (picHeight / picWidth * width);
    this.PictureFrame.Height = (double) num;
    // ISSUE: explicit non-virtual call
    // ISSUE: explicit non-virtual call
    __nonvirtual (((FrameworkElement) this).Height) = __nonvirtual (((FrameworkElement) this).Height) + (double) (num - height);
  }

  private void ShowTextBox_Click(object sender, RoutedEventArgs e)
  {
    if (this.HistoryTextBox.Visibility == Visibility.Collapsed)
    {
      // ISSUE: explicit non-virtual call
      // ISSUE: explicit non-virtual call
      __nonvirtual (((FrameworkElement) this).Height) = __nonvirtual (((FrameworkElement) this).Height) + 120.0;
      this.HistoryTextBox.Visibility = Visibility.Visible;
      this.ShowTextBoxButton.Content = (object) "5";
    }
    else
    {
      // ISSUE: explicit non-virtual call
      // ISSUE: explicit non-virtual call
      __nonvirtual (((FrameworkElement) this).Height) = __nonvirtual (((FrameworkElement) this).Height) - 120.0;
      this.HistoryTextBox.Visibility = Visibility.Collapsed;
      this.ShowTextBoxButton.Content = (object) "6";
    }
  }

  private void SaveComment_Click(object sender, RoutedEventArgs e)
  {
    TxApplication.ActiveUndoManager.StartTransaction();
    try
    {
      this.SmartNodeData.Apply();
    }
    finally
    {
      TxApplication.ActiveUndoManager.EndTransaction();
      TxApplication.RefreshDisplay();
    }
  }

  public override void getMaxZeroSize(ref System.Drawing.Point bottomRight)
  {
    // ISSUE: explicit non-virtual call
    bottomRight.X = (int) __nonvirtual (((FrameworkElement) this).Width);
    // ISSUE: explicit non-virtual call
    bottomRight.Y = (int) (__nonvirtual (((FrameworkElement) this).Height) + 120.0);
  }

  private void StatusComboBox_SelectionChanged(object sender, EventArgs e)
  {
    this.enableApplyButton();
  }

  private void DescriptionTextBox_TextChanged(object sender, RoutedEventArgs e)
  {
    this.SmartNodeData.DescText = this.DescriptionTextBox.Text;
    this.enableApplyButton();
  }

  private void HistoryTextBox_TextChanged(object sender, RoutedEventArgs e)
  {
    this.SmartNodeData.HistoryText = this.HistoryTextBox.Text;
    this.enableApplyButton();
  }

  private void enableApplyButton()
  {
    if (!this.m_isObjectSet)
      return;
    this.SmartNodeData.UpdateApply();
  }

  private void NextMedia_Click(object sender, RoutedEventArgs e)
  {
    if (!this.m_isObjectSet)
      return;
    this.SmartNodeData.SetNextMedia();
  }

  private void PrevMedia_Click(object sender, RoutedEventArgs e)
  {
    if (!this.m_isObjectSet)
      return;
    this.SmartNodeData.SetPrevMedia();
  }

  private void DeleteMedia_Click(object sender, RoutedEventArgs e)
  {
    if (!this.m_isObjectSet)
      return;
    this.SmartNodeData.DeleteCurrentMedia();
    if (this.SmartNodeData.NumberOfMedia == 0)
      this.CalcWindowHeight((double) this.SmartNodeData.PicContainer.Width, (double) this.SmartNodeData.PicContainer.Height);
    this.enableApplyButton();
  }

  [DebuggerNonUserCode]
  [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  public void InitializeComponent()
  {
    if (this._contentLoaded)
      return;
    this._contentLoaded = true;
    Application.LoadComponent((object) this, new Uri("/DnProcessSimulateCommands;component/headupwindow/smartnoteheadupwindow/cuismartnoteheadupwindow.xaml", UriKind.Relative));
  }

  [DebuggerNonUserCode]
  [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  internal Delegate _CreateDelegate(Type delegateType, string handler)
  {
    return Delegate.CreateDelegate(delegateType, (object) this, handler);
  }

  [DebuggerNonUserCode]
  [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  [EditorBrowsable(EditorBrowsableState.Never)]
  void IComponentConnector.Connect(int connectionId, object target)
  {
    switch (connectionId)
    {
      case 1:
        this.SmartNodeData = (CApSmartNotePictureDataContainer) target;
        break;
      case 2:
        this.PictureFrame = (System.Windows.Controls.Image) target;
        break;
      case 3:
        this.PrevMedia = (Button) target;
        this.PrevMedia.Click += new RoutedEventHandler(this.PrevMedia_Click);
        break;
      case 4:
        this.NumOutOfMedia = (TextBlock) target;
        break;
      case 5:
        this.NextMedia = (Button) target;
        this.NextMedia.Click += new RoutedEventHandler(this.NextMedia_Click);
        break;
      case 6:
        this.DeleteMedia = (Button) target;
        this.DeleteMedia.Click += new RoutedEventHandler(this.DeleteMedia_Click);
        break;
      case 7:
        this.svg61 = (Canvas) target;
        break;
      case 8:
        this.cmdTrash24_1_ = (Canvas) target;
        break;
      case 9:
        this.Path_9752 = (Path) target;
        break;
      case 10:
        this.Path_9753 = (Path) target;
        break;
      case 11:
        this.Rectangle_10388 = (System.Windows.Shapes.Rectangle) target;
        break;
      case 12:
        this.Path_9754 = (Path) target;
        break;
      case 13:
        this.NoteGrid = (Grid) target;
        break;
      case 14:
        this.StatusComboBox = (ComboBox) target;
        this.StatusComboBox.SelectionChanged += new SelectionChangedEventHandler(this.StatusComboBox_SelectionChanged);
        break;
      case 15:
        this.DescriptionTextBox = (TextBox) target;
        this.DescriptionTextBox.TextChanged += new TextChangedEventHandler(this.DescriptionTextBox_TextChanged);
        break;
      case 16 /*0x10*/:
        this.ShowTextBoxButton = (Button) target;
        this.ShowTextBoxButton.Click += new RoutedEventHandler(this.ShowTextBox_Click);
        break;
      case 17:
        this.HistoryTextBox = (TextBox) target;
        this.HistoryTextBox.TextChanged += new TextChangedEventHandler(this.HistoryTextBox_TextChanged);
        break;
      case 18:
        this.ApplyButton = (Button) target;
        this.ApplyButton.Click += new RoutedEventHandler(this.SaveComment_Click);
        break;
      default:
        this._contentLoaded = true;
        break;
    }
  }
}
